package com.xzcedu.printstream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 徐州城
 * @version 1.0
 * 演示 PrintWriter 使用方式 (字符打印流)
 */
public class PrintWriter_ {
    public static void main(String[] args) throws IOException {

        PrintWriter printWriter = new PrintWriter(System.out);
        printWriter.print("hi , 北京");
        printWriter.close();

        PrintWriter printWriter1 = new PrintWriter(new FileOutputStream("e:\\f2.txt"));
        printWriter1.print("Hello, World!!!");
        printWriter1.close(); //flush + 关闭流，才会将数据写入到文件..
    }
}
